# -*- coding: utf-8 -*- 
import m_main
import m_database

#在win7系统下需要把这一段注释掉的代码启用
import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
    reload(sys)
    sys.setdefaultencoding(default_encoding)

if __name__=='__main__':
    while True:
        ilist=[]
        xxx=m_database.MyDatabaseTmall()
        mytuple=xxx.fetchdata('select userid,usercode from customer where usetag is null and usercode is not null limit 200')
        
        for x,y in mytuple:
            task1=m_main.Task()
            task1.to_downloader='Downloader_Common'
            task1.to_spider='Spiders_Findcustomer_Judgerecord'
            task1.url='http://rate.taobao.com/member_rate.htm?callback=shop_rate_list&content=1&result=&from=rate&user_id='+y+'&identity=1&rater=3&direction=1&page=1'
            task1.refdata={'customerName':y}
            task1.header={'Referer':'http://detail.tmall.com/item.htm?id='+x}
            ilist.append(task1)
        m_main.scrapyEngine(ilist)
